<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="处方号">
              <a-input placeholder="处方号" v-model="queryParam.pspNum"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="医院名称">
              <a-input placeholder="医院名称" v-model="queryParam.hospitalName"></a-input>
            </a-form-item>
          </a-col>
        <template v-if="toggleSearchStatus">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="出库状态">
              <a-input placeholder="请输入出库状态" v-model="queryParam.outboundStatus"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="煎药状态">
              <a-input placeholder="请输入煎药状态" v-model="queryParam.jianyaoStatus"></a-input>
            </a-form-item>
          </a-col>
          <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="下发状态">
              <a-input placeholder="请输入下发状态" v-model="queryParam.issuedStatus"></a-input>
            </a-form-item>
          </a-col> -->
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('煎药中心vue页面增删改查')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <!-- 操作列太窄，导致删除提示框变形 -->
        <!-- 解决方法，将span改成div 并自定义样式  style='min-width: 150px' -->
        <div style='min-width: 150px' slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </div>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <dhyprescription-modal ref="modalForm" @ok="modalFormOk"></dhyprescription-modal>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import DhyprescriptionModal from './modules/DhyprescriptionModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'

  export default {
    name: "DhyprescriptionList",
    mixins:[JeecgListMixin],
    components: {
      DhyprescriptionModal
    },
    data () {
      return {
        description: '煎药中心处方数据',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
           },
		   {
            title: '委托单号',
            align:"center",
            dataIndex: 'delnum'
           },
		   {
            title: '医院名称',
            align:"center",
            dataIndex: 'hospitalName'
           },
		   {
            title: '处方号',
            align:"center",
            dataIndex: 'pspNum'
           },
        {
            title: '出库状态',
            align:"center",
            dataIndex: 'outboundStatus_dictText'
           },
		   {
            title: '煎药状态',
            align:"center",
            dataIndex: 'jianyaoStatus_dictText'
           },
		   {
            title: '患者姓名',
            align:"center",
            dataIndex: 'name'
           },
		   {
            title: '性别',
            align:"center",
            width: 80,
            dataIndex: 'sex_dictText'
           },
		   {
            title: '年龄',
            align:"center",
            dataIndex: 'age'
           },
		   {
            title: '电话',
            align:"center",
            dataIndex: 'phone'
           },
		   {
            title: '地址',
            align:"center",
            dataIndex: 'address'
           },
		   {
            title: '科室',
            align:"center",
            dataIndex: 'department'
           },
		   {
            title: '病区',
            align:"center",
            dataIndex: 'inpatientarea'
           },
		   {
            title: '病房',
            align:"center",
            dataIndex: 'ward'
           },
		   {
            title: '病床',
            align:"center",
            dataIndex: 'sickbed'
           },
		   {
            title: '诊断结果',
            align:"center",
            dataIndex: 'diagresult'
           },
		   {
            title: '贴数',
            align:"center",
            dataIndex: 'dose'
           },
		   {
            title: '次数',
            align:"center",
            dataIndex: 'takenum'
           },
		   {
            title: '取药时间',
            align:"center",
            dataIndex: 'getdrugtime'
           },
		   {
            title: '取药序号',
            align:"center",
            dataIndex: 'getdrugnum'
           },
		   {
            title: '煎药方案',
            align:"center",
            dataIndex: 'decscheme_dictText'
           },
		   {
            title: '一煎时间',
            align:"center",
            dataIndex: 'oncetime'
           },
		   {
            title: '二煎时间',
            align:"center",
            dataIndex: 'twicetime'
           },
		   {
            title: '包装量',
            align:"center",
            dataIndex: 'packagenum'
           },
		   {
            title: '记录时间',
            align:"center",
            dataIndex: 'dotime'
           },
		   {
            title: '操作人员',
            align:"center",
            dataIndex: 'doperson'
           },
		   {
            title: '收件方',
            align:"center",
            dataIndex: 'dtbcompany'
           },
		   {
            title: '收件地址',
            align:"center",
            dataIndex: 'dtbaddress'
           },
		   {
            title: '联系电话',
            align:"center",
            dataIndex: 'dtbphone'
           },
		   {
            title: '快递类型',
            align:"center",
            dataIndex: 'dtbtype_dictText'
           },
		   {
            title: '浸泡加水量',
            align:"center",
            dataIndex: 'soakwater'
           },
		   {
            title: '浸泡时间',
            align:"center",
            dataIndex: 'soaktime'
           },
		   {
            title: '标签数量',
            align:"center",
            dataIndex: 'labelnum'
           },
		   {
            title: '备注',
            align:"center",
            dataIndex: 'remark'
           },
		   {
            title: '医生',
            align:"center",
            dataIndex: 'doctor'
           },
		   {
            title: '医生脚注',
            align:"center",
            dataIndex: 'footnote'
           },
		   {
            title: '下单时间',
            align:"center",
            dataIndex: 'ordertime'
           },
		   {
            title: '处方状态',
            align:"center",
            dataIndex: 'curstate'
           },
		   {
            title: '煎药方式',
            align:"center",
            dataIndex: 'decmothed_dictText'
           },
		   {
            title: '服用方法',
            align:"center",
            dataIndex: 'takeWay_dictText'
           },
		   {
            title: '服用方式',
            align:"center",
            dataIndex: 'takemethod'
           },
		   {
            title: '备注A',
            align:"center",
            dataIndex: 'remarka'
           },
		   {
            title: '备注B',
            align:"center",
            dataIndex: 'remarkb'
           },
		   {
            title: '药品总数量',
            align:"center",
            dataIndex: 'drugCount'
           },
		   {
            title: '是否代煎',
            align:"center",
            dataIndex: 'isdaijian_dictText'
           },
		   {
            title: '支付方式',
            align:"center",
            dataIndex: 'payment'
           },
		   {
            title: '医嘱',
            align:"center",
            dataIndex: 'yizhu'
           },
		   {
            title: '金额',
            align:"center",
            dataIndex: 'money'
           },
		   {
            title: '病历号',
            align:"center",
            dataIndex: 'outpatientnumber'
           },
		  //  {
      //       title: '序号',
      //       align:"center",
      //       dataIndex: 'outpatientIndex'
      //      },
		   {
            title: '处方类型',
            align:"center",
            dataIndex: 'ptype_dictText'
           },
		   {
            title: '特殊群体',
            align:"center",
            dataIndex: 'particular_dictText'
           },
		   {
            title: '身份验证',
            align:"center",
            dataIndex: 'token'
           },
        {
            title: '重新下发时间',
            align:"center",
            dataIndex: 'reorderDate'
           },
		   {
            title: '重新下发人ID',
            align:"center",
            dataIndex: 'reorderStaffId'
           },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
		url: {
          list: "/jianyao/dhyprescription/list",
          delete: "/jianyao/dhyprescription/delete",
          deleteBatch: "/jianyao/dhyprescription/deleteBatch",
          exportXlsUrl: "jianyao/dhyprescription/exportXls",
          importExcelUrl: "jianyao/dhyprescription/importExcel",
       },
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
    methods: {

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>